package crp.services.api.graphql.models;

import crp.core.student.domain.models.StudentEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import org.eclipse.microprofile.graphql.Id;
import org.eclipse.microprofile.graphql.Type;

import javax.validation.constraints.NotNull;

@Type("Student")
@Builder
@Getter
@AllArgsConstructor
public class StudentPayload {
    @Id
    @NotNull
    private final String id;
    @NotNull
    private final String studentNo;
    @NotNull
    private final String name;

    public static StudentPayload of(StudentEntity entity) {
        return StudentPayload.builder()
                .id(entity.getId())
                .studentNo(entity.getStudentNo())
                .name(entity.getName())
                .build();
    }
}
